//
//  WebBrowserController.m
//  History
//
//  Created by kane on 16/9/7.
//  Copyright © 2016年 kane. All rights reserved.
//

#import "WebBrowserController.h"

@interface WebBrowserController ()<UIWebViewDelegate>
{
    __weak IBOutlet UIWebView *browser;
}
@end

@implementation WebBrowserController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    NSString *url = @"http://a1.go2yd.com/Website/contents/content?version=010915&distribution=com.apple.appstore&appid=history&cv=2.2.0.0&platform=0&net=wifi&version=010915&distribution=com.apple.appstore&appid=history&cv=2.2.0.0&platform=0&net=3G&appid=history&bottom_channels=true&bottom_comments=true&cv=2.2.0.0&distribution=com.apple.appstore&docid=0EMjp6C6&highlight=true&net=wifi&platform=0&related_docs=true&version=010915";
    NSError *error;
    //加载一个NSURL对象
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
    NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableLeaves error:&error];
    NSString *htmlString = [dict objectForKey:@"documents"][0][@"content"];
    [browser loadHTMLString:htmlString baseURL:nil];
}

- (void)webViewDidStartLoad:(UIWebView *)webView
{
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
